﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RayDen.Library.Core;
using RayDen.RayEngine.Core.Interface;

namespace RayDen.SmallRT.Components
{
    public abstract class BaseIntegrator
    {
        protected Brdf[] Brdfs = 
        {
            new Lambertian(),
            new SpecularReflection(),
            new SpecularRefraction(),
            new Lambertian(),

        };

        protected int Threads = 8;
        internal SceneManager Scene;
        internal int Pass;
        internal IRandomProvider rnd;

        internal IImageFilm film;

        public abstract void RenderPass();

        public abstract void InitPass();

        public virtual string GetStats()
        {
            return string.Empty;
        }

        internal virtual void RunRenderer(System.Threading.CancellationToken cancellationToken)
        {
            Parallel.For(0, Threads, new ParallelOptions()
            {
                CancellationToken = cancellationToken,
                MaxDegreeOfParallelism = Threads
            }, (i) =>
                   {
                       this.InitPass();
                       this.RenderPass();
                   });
        }
    }


}
